<?php

//-----------------------------------------------------------------------------

function f_view_home() {
    f_head();
    f_body_start();
    //f_info();
    f_title('Welcome');
    f_login();
    $s = <<<EOT
<div>Welcome to the repository of patterns. Here you can create and submit to the community a new pattern or evaluate previously made patterns.<br/>
In order to do so, you must log in and have the needed rights.</div>
EOT;
    echo $s;
    f_body_end();
}

//-----------------------------------------------------------------------------

function f_view_new() {
    f_head();
    f_body_start();
    //f_info();
    f_title("Create New Pattern");
    f_login();
    if ($_SESSION['page'] != 'End') {
        f_menu();
        f_form_start();    
        include('html/' . $_SESSION['pages'][$_SESSION['page']]);
    } else {
        include('html/form_end.html');
    }

    /*    
    switch($_SESSION['page']) {
        case 'Base':
            include('form_base.html');
            break;
        case 'S&D and RCES':
            include(
            break;
        case 'Quality and Needs':
            break;
        case 'Deployment and Services':
            break;
        case 'Static and dynamic structures':
            break;
    }
    */
    f_form_end();
    f_body_end();
}

//-----------------------------------------------------------------------------

function f_view_browse() {
    f_head();
    f_body_start();
    //f_info();
    f_title('Browse Patterns');
    f_login();

    echo "<div>Display the patterns saved into the repository. Click on one of them to see it in detail and notes attached.</div>";

    $patterns = f_get_patterns();
    echo "<ul>";
    foreach($patterns as $pattern) {
        echo '<li><a href="index.php?action=browse&id=' . $pattern[0] . '">'. $pattern[2] . " ( " . $pattern[3] . ") </a><i>published by " . $pattern[1] . "</i> ( " . $pattern[4] . " notes)</li>";
    }
    echo "</ul>";

    f_body_end();
}

//-----------------------------------------------------------------------------

function f_view_register() {

    f_head();
    f_body_start();
    //f_info();
    f_title("Register a new user");
    f_login();

    include("html/register_form.html");

    f_body_end();
}

?>

